package com.hello.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import com.hello.mapper.UserMapper;
import com.hello.pojo.User;
import com.hello.service.UserService;
@Component(value="UserService")
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
	@Override
	public User findUserByName(String username) {
		// TODO Auto-generated method stub
		return userMapper.selectByName(username);
	}
	@Override
	public void saveUser(User user) {
		// TODO Auto-generated method stub
		userMapper.insertUser(user);
	}
	@Override
	public void checkUser(User user) {
		// TODO Auto-generated method stub
		if(user.getUsername()!=null&&user.getPassword()!=null&&user.getUsername()!=""&&user.getPassword()!="") {
			if(userMapper.selectByName(user.getUsername())==null) {
				
				userMapper.insertUser(user);
			}
			
		}
	}

}
